/*
* $Id: debug.h,v 1.17 2007/10/25 02:45:26 chunchia Exp $
*/
/*******************************************************************************

       UBEC (Uniband Electronic Corp.)

       Project: U-NET01, Ubiquitous network platform

       File: debug.h

       Version: 0.3.0

       Usage: Debug message

       Platform: U-NET01 DK with Keil 8051 C compiler

       Reference:

               Silicon Laboratories: C8051F124, C8051F340

               UBEC: UZ2400, UZ2410

       Note :

               Copyright (C) 2007 Uniband Electronic Corporation, All rights reserved

********************************************************************************/

/*******************************************************************************

	Debug Function

********************************************************************************/

#ifndef	__DEBUG_H__
#define	__DEBUG_H__

#if	DEBUG_MODE
	#define	SEND_MSG_TIME_STAMP		1	// 2007/2/11 22:53:58, Sunny: 1: enable debug message time stamp
#else
	#define	SEND_MSG_TIME_STAMP		0	// 2007/2/11 22:53:58, Sunny: 0: disable debug message time stamp
#endif // #if	DEBUG_MODE


// ************************************************************************************************
// 2003/6/03, Sunny: functions and macros for program tracing/debugging
// ************************************************************************************************
#if DEBUG_MODE
	void print_TRACE_TAG(char const *file, int line);
	void do_TRACE_TAG(char const *file, int line);

    #if SEND_MSG_TIME_STAMP
	extern BOOL dbg_time_stamp_ctrl;
	#define dbg_time_stamp(ctrl)		dbg_time_stamp_ctrl = ctrl
	#define is_dbg_time_stamp()		dbg_time_stamp_ctrl
    #else
	#define dbg_time_stamp(ctl)
	#define is_dbg_time_stamp()
    #endif // #if SEND_MSG_TIME_STAMP

// 2007/2/11 22:53:58, Sunny: macros for program tracing
	#define	DBG_putchar(c)	{ dbg_time_stamp(1); putchar(c); dbg_time_stamp(0); }
	#define	DBG_puts(s)	{ dbg_time_stamp(1); puts(s); dbg_time_stamp(0); }
	#define dbg_printf      printf
	#define	DBG_printf(P)	{ dbg_time_stamp(1); dbg_printf P; dbg_time_stamp(0); }
	#define TRACE_puts(s)   { dbg_time_stamp(1); print_TRACE_TAG(__FILE__, __LINE__); puts(s); dbg_time_stamp(0); }
	#define	TRACE_printf(P)	{ dbg_time_stamp(1); print_TRACE_TAG(__FILE__, __LINE__); dbg_printf P; dbg_time_stamp(0); }
	#define	TRACE_TAG()	{ dbg_time_stamp(1); do_TRACE_TAG(__FILE__, __LINE__); dbg_time_stamp(0); }
#else	// 2007/2/11 22:53:58, Sunny: quick method to disable all tracing/debugging messages
	#define	DBG_putchar(c)
	#define	DBG_puts(s)
	#define	DBG_printf(P)
	#define TRACE_puts(s)
	#define	TRACE_printf(P)
	#define	TRACE_TAG()
#endif
#endif // #ifndef	__DEBUG_H__
